﻿using EasyToHelp.DBFactory;
using EasyToHelp.Entity;
using System;
using System.Collections.Generic;
using System.Text;

namespace EasyToHelp.Service
{
    public class MarketService: IMarketService
    {
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(Market model)
        {
            return DBHelper.InsertExecute<Market>(model).Id;
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Update(Market model)
        {
            return DBHelper.UpdateExecute<Market>(model);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Delete(Market model)
        {
            return DBHelper.DeleteExecute<Market>(model);
        }
        /// <summary>
        /// 获取所有市场
        /// </summary>
        /// <returns></returns>
        public List<Market> GetList()
        {
            using (var db = ContextHelper.Context(ContextHelper._connString))
            {
                return db.Query<Market>().ToList();
            }
        }

    }
}
